home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-17 | 3.6 KB | 134 lines |
- ' ************************************* Commands used:
- ' * * Vec Rot Pos Blitter Clear
- ' * Amcaf Examples * Vec Rot Angles =Qsin
- ' * Vector Rotate Solid+Glenz V1.1 * Vec Rot Precalc
- ' * Written by Chris Hodges * =Vec Rot X
- ' * * =Vec Rot Y
- ' ************************************* =Vec Rot Z
- '
- ' Kill the mouse
- Hide
- ' Setup a nice little screen with double buffering
- Screen Open 0,320,256,4,Lowres
- Curs Off : Flash Off : Paper 0 : Pen 1 : Cls
- Palette $40,$8C8,$484,$AFA
- Double Buffer
- Autoback 0
- ' Read out, how many coords are used.
- Restore COORDS
- Read NUMCO
- ' Dim one field to keep these coords, and a second for the rotated.
- Dim CO(NUMCO,2),RC(NUMCO,1)
- ' Now read all coords in.
- For A=1 To NUMCO
- Read CO(A,0),CO(A,1),CO(A,2)
- Next
- ' Then, get the number of shapes the object consists of.
- Restore SHAPES
- Read NUMLI
- ' Dim a field to hold the three coords.
- Dim LI(NUMLI,2)
- ' Get the datas.
- For A=1 To NUMLI
- Read LI(A,0),LI(A,1),LI(A,2)
- Next
- ' Set the three angles. Remember that these are non standard angles,
- ' one full rotation is at 1024, not 360!
- AX=0 : AY=512 : AZ=128
- Repeat
- ' Start clearing bitplane 0.
- Extension_8_121C 0,0
- ' While the blitter is working, use the time to calculate the rotations.
- ' Move and set the angles.
- Add AX,4
- Add AY,7
- Add AZ,24
- Extension_8_1138 AX,AY,AZ
- ' Calculate the distances by using a sine-function and the three angles.
- POSX= Extension_8_1106(AX,300)
- POSY= Extension_8_1106(AY,300)
- POSZ= Extension_8_1106(AZ,500)+1500
- ' Set the camera positions.
- Extension_8_1122 POSX,POSY,POSZ
- ' Now it's time to compute the matrix.
- Extension_8_1152
- ' Clear bitplane 1
- Extension_8_121C 0,1
- ' So let's rotate all coordinates of the field CO()
- For A=1 To NUMCO
- ' Note: You only have to use the vec rot function with parameters once.
- RC(A,0)= Extension_8_1168(CO(A,0),CO(A,1),CO(A,2))+160
- RC(A,1)= Extension_8_1184 +128
- Next
- ' It's time to finally get the polygons to the screen!
- For A=1 To NUMLI
- ' Get the three coordinates pairs.
- C1=LI(A,0) : C2=LI(A,1) : C3=LI(A,2)
- ' Get the rotated coordinates
- X1=RC(C1,0) : Y1=RC(C1,1)
- X2=RC(C2,0) : Y2=RC(C2,1)
- X3=RC(C3,0) : Y3=RC(C3,1)
- ' Use some maths, to see if the plane faces into the camera or into
- ' the back. This formula works ONLY, if the polygon is drawn
- ' anticlockwise!
- DI=(X3-X1)*(Y2-Y1)-(X2-X1)*(Y3-Y1)
- If DI<0
- ' Draw the polygons in bitplane 1
- Extension_8_1016 X1,Y1 To X2,Y2,2,-2
- Extension_8_1016 X2,Y2 To X3,Y3,2,-2
- Extension_8_1016 X3,Y3 To X1,Y1,2,-2
- Else
- ' Draw the polygons in bitplane 0
- Extension_8_1016 X1,Y1 To X2,Y2,1,-1
- Extension_8_1016 X2,Y2 To X3,Y3,1,-1
- Extension_8_1016 X3,Y3 To X1,Y1,1,-1
- End If
- Next
- ' Fill both bitplanes.
- Extension_8_1042 0,0
- Extension_8_1042 0,1
- ' Swap the screens to bring the object to view.
- Screen Swap
- Wait Vbl
- Until Inkey$=Chr$(27) or Mouse Key<>0
- Screen Close 0
- End
- ' 1_____2
- ' 5/____/|
- ' | | |6|
- ' |4|__|_|3
- ' |/___|/
- ' 8 7
- COORDS:
- Data 14
- ' POLYEDER
- Data -100,-100,-100
- Data 100,-100,-100
- Data 100,-100,100
- Data -100,-100,100
- Data -100,100,-100
- Data 100,100,-100
- Data 100,100,100
- Data -100,100,100
- Data 0,-175,0
- Data 175,0,0
- Data 0,175,0
- Data -175,0,0
- Data 0,0,175
- Data 0,0,-175
-
- SHAPES:
- Data 12
- ' All lines are drawn in anticlockwise.
- Data 1,9,4
- Data 2,3,9
- Data 11,7,6
- Data 5,8,11
- Data 4,3,13
- Data 8,13,7
- Data 14,2,1
- Data 6,14,5
- Data 2,6,10
- Data 3,10,7
- Data 12,5,1
- Data 8,12,4